package com.icebergteam.warfacewidget.rank.ui;

import java.util.ArrayList;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.icebergteam.warfacewidget.R;
import com.icebergteam.warfacewidget.rank.ClassHelper;
import com.icebergteam.warfacewidget.rank.RankHelper;
import com.icebergteam.warfacewidget.rank.data.Top100Item;
import com.icebergteam.warfacewidget.rank.data.TopUsersItem;

public class TopUsersModelAdapter extends ArrayAdapter<TopUsersItem> {
	public final String className = TopUsersModelAdapter.class.getCanonicalName();
	
	private ArrayList<TopUsersItem> listTopUserstems;
	
	public TopUsersModelAdapter(Context context, int textViewResourceId, ArrayList<TopUsersItem> topUsers) {
		super(context, textViewResourceId, topUsers);
		
		this.listTopUserstems = topUsers;
	}
	
	static public View getViewWithParam(Context context, View convertView, TopUsersItem topUsersItem) {
		View v = convertView;
		if(v == null) {
			LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.top_users_list_item_widget_layout, null);
		}
		
		if(topUsersItem != null) {
			TextView text1 = (TextView) v.findViewById(R.id.textView1);
			TextView text2 = (TextView) v.findViewById(R.id.textView2);
			TextView text3 = (TextView) v.findViewById(R.id.textView3);
			TextView text4 = (TextView) v.findViewById(R.id.textView4);
			TextView text5 = (TextView) v.findViewById(R.id.textView5);
			
			text1.setText(String.format("%s", topUsersItem.getRank()));
			text2.setText(String.format("%s", topUsersItem.getName()));
			text3.setText(String.format("%s", topUsersItem.getUserRating()));
			text4.setText(String.format("%s", topUsersItem.getMonthRating()));
			text5.setText(String.format("%s", topUsersItem.getClansRating()));
			
			
		}
		return v;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return getViewWithParam(getContext(), convertView, listTopUserstems.get(position));
	}
}